package com.his.inspection.controller;

import com.his.common.Result;
import com.his.inspection.pojo.Employee;
import com.his.inspection.pojo.MedicalTechnology;
import com.his.inspection.pojo.Register;
import com.his.inspection.service.InspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;



@RestController
@CrossOrigin("*")
@RequestMapping("inspection")
public class InspectionController {
    @Autowired
    private InspectionService inspectionService;

    @GetMapping("query")
    public Result queryAllInspection(){
        ArrayList<Register> inspection=inspectionService.queryAllInspection();
        System.out.println(inspection);
        if(inspection!=null){
            return new Result(1,"查询检验申请信息列表成功！",inspection);
        }
        else{
            return new Result(0,"查询检验申请信息列表失败！",null);
        }
    }

    @PostMapping("select")
    public Result queryInspectionByConditions(@RequestBody Register register){
        ArrayList<Register> list=inspectionService.queryInspectionByConditions(register);
        System.out.println(list);
        if(list!=null){
            return new Result(1,"条件查询检验申请信息成功！",list);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
    //根据id拿到患者信息
    @PostMapping("lectById")
    public Result selectById(Integer id){
        Register register =inspectionService.selectById(id);
        System.out.println(register);
        return Result.success(register);
    }

    @PostMapping("select1")
    public Result queryEmployeeByConditions(@RequestBody Employee employee){
        ArrayList<Employee> list=inspectionService.queryEmployeeByConditions(employee);
        if(list!=null){
            return new Result(1,"条件查询检验申请信息成功！",list);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
    @PostMapping("select2")
    public Result queryMedicalTechnologyByConditions(Integer id) {
        ArrayList<MedicalTechnology> medicalTechnologyArrayList=inspectionService.queryMedicalTechnonlgyByConditions(id);
        if(medicalTechnologyArrayList!=null){
            return new Result(1,"条件查询检验申请信息成功！",medicalTechnologyArrayList);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
}
